//位运算+思维
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N = 2e5 + 10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
ll n, a[100];
void solve()
{
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++)
    {
        ll x;
        cin>>x;
        ans|=x;
    }

    // ll ans = 0;
    // for(int i = 1; i <= n; i++) ans |= a[i];

    cout << ans << '\n';



}

int main()
{
    close();
    int T;
    cin >> T;
    while (T--) solve();
    return 0;
}